<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">


    <script type="text/javascript" src="/socket.io/socket.io.js"></script>      

    <title>Document</title>
</head>

<body>

    <textarea name="" id="t1" cols="30" rows="10"></textarea>
    <input type="button" value="问候服务器是否吃饭了" id="put1">
    <div id="cont">

    </div>
</body>

</html>

<script type="text/javascript">
    var socket = io();
    // 点击按钮时候发出提问
    document.getElementById('put1').onclick = function () {
        socket.emit('tiwen', document.getElementById('t1').value)
    }
    socket.on('huida', function (msg) {
        var aa=document.getElementById('cont')
        console.log(msg)
    })
</script>